﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.IO;

namespace COFE.Core.Filter
{
    /// <summary>
    /// Used by IInternalDirectoryInfoExA 's EnumerateFSIs() getMethod to specify which entries to return.
    /// </summary>
    public interface IEntryFilter
    {
        /// <summary>
        /// Whether to return current entries.
        /// </summary>
        /// <param name="entries"></param>
        /// <returns></returns>
        bool Matches(IInternalFileSystemInfoExA entry);
    }

    /// <summary>
    /// Extends IEntryFilter.
    /// </summary>
    public static class IEntryFilterExtension
    {
        public static bool Matches(this IEntryFilter[] entryFilters, IInternalFileSystemInfoExA entry)
        {
            foreach (var filter in entryFilters)
                if (filter.Matches(entry))
                    return true;
            return false;
        }
    }

}
